package Model.Stances;

import java.awt.Point;

import Model.Visible.Planet;
import Model.Visible.Ship;
import Utils.ConstantsImplement;
import Utils.Timers.Timer;
import Utils.Timers.TimerListener;

public class FleetMaker extends Stances implements ConstantsImplement, TimerListener{
	
	private long constructionSpeed_;
	private int shipsInContruction_;
	private boolean available_ = true;
	private Timer timer_;
	private int ship_lvl_;
	private int shipPrice_;
	
	public FleetMaker(Planet planet){
		super(planet);
		planet_ = planet;
		constructionSpeed_ = 0;
		price_ = INITIAL_FLEET_MAKER_PRICE;
		shipPrice_ = INITIAL_SHIP_PRICE;
	}
	
	public void updateStance(){
		if(planet_.getResources() >= this.price_){
			super.updateStance();
			this.price_ = price_+INCREMENT_FLEET_MAKER_PRICE;
			constructionSpeed_ = constructionSpeed_+SPEED_INCREMENT;
		}
	}
	
	public void sellStance(){
		super.sellStance();
		this.price_ = price_-INCREMENT_INDUSTRY_PRICE;
		constructionSpeed_ = constructionSpeed_-SPEED_INCREMENT;
}
	
	public int construct(int num, Planet planet){
		ship_lvl_ = level_;
		for (int i = 0; i < num; i++) {
					planet_.getFleet_().addShip(new Ship( new Point(0,0), level_));
		}
//		
//		if( (num * INITIAL_SHIP_PRICE * level_ > planet.getResources()) &&  available_ ){
//			//implementar aviso sobre falta de recursos
//			return -1;
//		}
//		else{
//			timer_ = new Timer( this, constructionSpeed_);
//			shipsInContruction_ = num;
//			timer_.start();
//		}
//		return 0;
		return 0;
	}
	
	public int getShipPrice_() {
		return shipPrice_;
	}

	public void setShipPrice_(int shipPrice_) {
		this.shipPrice_ = shipPrice_;
	}

	public void update(){
		if ( shipsInContruction_ > 0 ){
			//System.out.println("Nova Ship");
		planet_.getFleet_().addShip(new Ship( new Point(0,0), level_));
		shipsInContruction_--;
		}
	}

}
